﻿IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_GetActiveJPushMessage]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[sp_GetActiveJPushMessage]
GO

CREATE PROCEDURE [dbo].[sp_GetActiveJPushMessage]
AS

BEGIN
    SELECT [Key]
      ,[MessageId]
      ,[Audience]
      ,[Platform]
      ,[AppMessage]
      ,[Notification]
      ,[ResponseCode]
      ,[ResponseMessage]
      ,[AndroidDeliveredCount]
      ,[ApplePushNotificationDeliveredCount]
      ,[WindowsPhonePushNotificationDeliveredCount]
      ,[IsTest]
      ,[CreatedStamp]
      ,[LastUpdatedStamp]
  FROM [dbo].[JPushMessageLog]
  WHERE DATEADD(hh, 240, [CreatedStamp]) >= GETUTCDATE();

END
GO